/*
 * @(#)ModController.java 2012-02-02
 *
 * Copyright 2011 北龙中网（北京）科技有限责任公司. All rights reserved.
 */
package cn.shangjia.shop.controller.mod;

import java.util.Collection;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.shangjia.common.domain.Group;
import cn.shangjia.common.domain.ProductOnline;
import cn.shangjia.common.util.StringUtils;
import cn.shangjia.search.common.bean.CmsInformationBean;
import cn.shangjia.shop.service.GroupService;
import cn.shangjia.shop.service.ProductService;
import cn.shangjia.shop.service.SolrQueryService;

/**
 *
 * @author <a href="mailto:jinzhongze@knet.cn">jinzhongze</a>
 * @version 1.0, 2012-02-02 09:51:42
 * @since 1.0
 */
@Controller
public class IndexMod {
	
	@Resource
	private ProductService productOnlineService;
	
	@Resource
	private SolrQueryService solrQueryService;
	
	@Resource
	private GroupService groupService;
	
//	@Resource
//	private CompanyInfoService companyInfoService;
	
	/**
	 *  主题模块 - 企业名片
	 * 
	 * @param model
	 * @author <a href="mailto:jinzhongze@knet.cn">jinzhongze</a>
	 */
	@RequestMapping("/shop/module/index/ind_companyCard.html")
	public void ind_companyCard(ModelMap model) {
		
	}
	
	/**
	 *  主题模块 - 供求信息
	 * 
	 * @param model
	 * @author <a href="mailto:jinzhongze@knet.cn">jinzhongze</a>
	 */
	@RequestMapping("/shop/module/index/ind_productInfo.html")
	public void ind_productInfo(ModelMap model) {
		
	}
	
	/**
	 *  主题模块 - 企业动态
	 * 
	 * @param model
	 * @author <a href="mailto:jinzhongze@knet.cn">jinzhongze</a>
	 */
	@RequestMapping("/shop/module/index/ind_companyNews.html")
	public void ind_companyNews(ModelMap model) {
		
	}
	
	/**
	 *  主题模块 - 企业介绍
	 * 
	 * @param model
	 * @author <a href="mailto:jinzhongze@knet.cn">jinzhongze</a>
	 */
	@RequestMapping("/shop/module/index/ind_companyIntro.html")
	public void ind_companyIntro(ModelMap model, String userid) {
		if (StringUtils.isEmpty(userid))
			return ;
		//商圈
		List<Group> groups = groupService.findGroupsByUserId(userid);
		model.addAttribute("groups", groups);
	}
	
	
	/**
	 *  主题模块 - 推荐资讯
	 * 
	 * @param model
	 * @author <a href="mailto:jinzhongze@knet.cn">jinzhongze</a>
	 */
	@RequestMapping("/shop/module/index/ind_commendNews.html")
	public void ind_commendNews(ModelMap model, String userid) {
//		if (StringUtils.isEmpty(userid))
//			return;
//		CompanyInfo info = companyInfoService.getCompanyInfoByUserId(userid);
//		if (info == null)
//			return;
//		CompanyBasicOnline basic = info.getCompanyBasicOnline();
//		List<CmsInformationBean> hotInfo = solrQueryService.findCmsInformation(basic.getBrand(), basic.getGbt());
		//由于 cms没有数据 所以 先取全部的
		List<CmsInformationBean> hotInfo = solrQueryService.findCmsInformation();
		model.addAttribute("hotInfo", hotInfo);
	}
	
	
	/**
	 *  主题模块 - 精品推荐
	 * 
	 * @param model
	 * @author <a href="mailto:jinzhongze@knet.cn">jinzhongze</a>
	 */
	@RequestMapping("/shop/module/index/ind_productCommend.html")
	public void ind_productCommend(ModelMap model, String userid) {
		Collection<ProductOnline> mod_pro_comend = productOnlineService.findProductRecommendListByUserId(userid, 1, 4).getResult();
		model.addAttribute("mod_pro_comend", mod_pro_comend);
	}
}
